package com.example.widgetcase.slice;

import com.example.widget_lib.widget.progress.circle.CircleProgress;
import com.example.widget_lib.widget.progress.circle.GradientProBar;
import com.example.widgetcase.ResourceTable;
import ohos.aafwk.content.Intent;

import java.security.SecureRandom;
import java.util.Random;

public class GradientProBarAbility extends BaseSlice {

    private SecureRandom mRandom = new SecureRandom();

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        CircleProgress bar1 = (CircleProgress) findComponentById(ResourceTable.Id_gradient_probar1);
        GradientProBar bar2 = (GradientProBar) findComponentById(ResourceTable.Id_gradient_probar2);

        findComponentById(ResourceTable.Id_flushBtn1).setClickedListener(component -> {
            bar1.setValue(mRandom.nextFloat() * bar1.getMaxValue());
        });

        bar2.setPercent(30);
        findComponentById(ResourceTable.Id_flushBtn2).setClickedListener(component -> {
            bar2.setPercent(mRandom.nextInt(100));
        });

    }

    @Override
    public int getChildUIContent() {
        return ResourceTable.Layout_gradient_probar;
    }
}
